<?php slot('sub', $sub); ?>

<div class="center">
    <div id="center_conteiner" class="clearfix">
        <div class="center_sub_conteiner">

            <div class="center_block">
                <div class="header_center_block"><span>Users</span></div>
                
                <div class="tabs_sort_by_title">Sort by</div>
                <div class="tabs_sort_by">
                    <ul>
                        <li class='active'>All</li>
                        <li>Users</li>
                        <li>Agents</li>
                        <li>Firm</li>
                        <li>Admin's</li>
                    </ul>
                    <hr>
                </div>
                
                <div class="pages_list">
                    <ul>
                        <li><<</li>
                        <li class='active'>1</li>
                        <li>>></li>
                    </ul>
                </div>

                <div class="users_title">
                    <div class="users_title_id">id</div>
                    <div class="users_title_title">title</div>
                    <div class="users_title_first_name">name</div>
                    <div class="users_title_status">status</div>
                    <div class="users_title_permissions">permissions</div>
                    <div class="add_new_user"><a href="<?php echo url_for('adduser'); ?>">Add</a></div>
                </div>

                <?php
                foreach ($users as $user) {
                    if ($user->getStatus() == 1) {
                        $status = 'active';
                    } else {
                        $status = 'deactivated';
                    }
                    
                    if ($user->getPermissions() == sbValues::PERMISSIONS_STANDART) {
                        $permissions = 'user';
                    } else if ($user->getPermissions() == sbValues::PERMISSIONS_AGENT) {
                        $permissions = 'agent';
                    } else if ($user->getPermissions() == sbValues::PERMISSIONS_FIRM) {
                        $permissions = 'firm';
                    } else if ($user->getPermissions() == sbValues::PERMISSIONS_ADMIN) {
                        $permissions = 'admin';
                    }
                    
                    if ($user->getStatus() == sbValues::STATUS_ACTIVE) {
                        $btnDelete = 'Deactivate';
                    } else {
                        $btnDelete = 'Activate';
                    }
                    
                    echo '<div class="user_line">'.
                    '<div class="user_line_id">'.$user->getId().'</div>' .
                    '<div class="user_line_title">'.$user->getTitle().'</div>'.
                    '<div class="user_line_name">'.$user->getFirstName()." ".$user->getLastName().'</div>'.
                    '<div class="user_line_status">'.$status.'</div>'.
                    '<div class="user_line_permissions">'.$permissions.'</div>'.
                    '<div class="user_line_edit_button"><a href="'.url_for('aedituser', array('user_id' => $user->getId())).'">Edit</a></div>'.
                    '<div class="user_line_delete_button"><a href="'.url_for('adeactivateuser', array('user_id' => $user->getId())).'">'.$btnDelete.'</a></div>'.
                    '</div>';
                }
                ?>

                <div class="pages_list">
                    <ul>
                        <li><<</li>
                        <li class='active'>1</li>
                        <li>>></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
